if( SERVER ) then
	AddCSLuaFile( "shared.lua" )
	SWEP.Weight	= 5
	SWEP.AutoSwitchTo = false
	SWEP.AutoSwitchFrom = false
end

if( CLIENT ) then
	SWEP.PrintName	= "Flash"
	SWEP.Slot	= 3
	SWEP.SlotPos	= 1
	SWEP.DrawAmmo	= false
	SWEP.DrawCrosshair = false
	SWEP.ViewModelFOV = 62
	SWEP.ViewModelFlip = true
	killicon.AddFont( "weapon_ent_flash", "CSKillIcons", "P", Color( 255, 80, 0, 255 ) )
	killicon.AddFont( "weapon_flash", "CSKillIcons", "P", Color( 255, 80, 0, 255 ) )
end

SWEP.Base		= "weapon_base"

SWEP.Author		= "Enrico"
SWEP.Instructions	= ""
SWEP.Contact		= ""
SWEP.Purpose		= ""

SWEP.Primary.ClipSize = -1
SWEP.Primary.DefaultClip = -1
SWEP.Primary.Automatic = false
SWEP.Primary.Ammo = "none"
SWEP.Secondary.ClipSize = -1
SWEP.Secondary.DefaultClip = -1
SWEP.Secondary.Automatic = false
SWEP.Secondary.Ammo = "none"

SWEP.Throw = nil

SWEP.ViewModel	= "models/weapons/v_eq_flashbang.mdl"
SWEP.WorldModel = "models/weapons/w_eq_flashbang.mdl"

util.PrecacheSound("weapons/iceaxe/iceaxe_swing1.wav")

function SWEP:Initialize()
	if( SERVER ) then
		self:SetWeaponHoldType( "grenade" )
	end
end

function SWEP:Deploy()
	self.Weapon:SendWeaponAnim( ACT_VM_DRAW )
	return true
end

function SWEP:PrimaryAttack()
	self.Weapon:SetNextPrimaryFire(CurTime()+1)
	self.Throw = CurTime() + 0.9
	self.Weapon:SendWeaponAnim( ACT_VM_PULLBACK_LOW )
end

function SWEP:Think()
	if self.Throw and self.Throw < CurTime() then
		self.Owner:EmitSound("weapons/iceaxe/iceaxe_swing1.wav")
		if (CLIENT) then return end
		local flash = ents.Create("weapon_ent_flashbang")
		flash:SetPos(self.Owner:GetShootPos() + self.Owner:GetCursorAimVector()*15)
		flash:SetAngles(self.Owner:GetCursorAimVector():Angle())
		flash:SetOwner(self.Owner)
		flash:Spawn()
		flash:Activate()
		self.Owner:StripWeapon("weapon_flash")
	end
end

function SWEP:DrawWeaponSelection( x, y, wide, tall, alpha )  
	draw.SimpleText( "P", "CSSelectIcons", x + wide/2, y + tall*0.2, Color( 255, 210, 0, 255 ), TEXT_ALIGN_CENTER )
end